#!/usr/bin/env python3
"""
Example script showing how to properly run casestab module
This demonstrates the correct way to import and use the casestab module
"""

import sys
import os

# Add the current directory to Python path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

# Now we can import the casestab module properly
from casestab import casestab
from casestab import math_functions as mf

def demonstrate_casestab_usage():
    """Demonstrate how to use the casestab module"""
    
    print("=== CASEStab Module Usage Examples ===\n")
    
    # Example 1: Using math_functions directly
    print("1. Using math_functions directly:")
    phi = 0.5  # radians
    R = mf.R3(phi)
    print(f"R3({phi}) = ")
    print(R)
    print()
    
    # Example 2: Show that casestab module is accessible
    print("2. CASEStab module is accessible:")
    print(f"rotor_models class: {casestab.rotor_models}")
    print()
    
    # Example 3: Show available functions in math_functions
    print("3. Available rotation functions in math_functions:")
    rotation_functions = [func for func in dir(mf) if func.startswith('R') and callable(getattr(mf, func))]
    for func in rotation_functions:
        print(f"  - {func}")
    print()
    
    # Example 4: Demonstrate R1, R2, R3 functions
    print("4. Comparison of R1, R2, R3 rotation matrices:")
    angle = np.pi/6  # 30 degrees
    R1_matrix = mf.R1(angle)
    R2_matrix = mf.R2(angle)
    R3_matrix = mf.R3(angle)
    
    print(f"R1(π/6) - rotation about x-axis:")
    print(R1_matrix)
    print(f"\nR2(π/6) - rotation about y-axis:")
    print(R2_matrix)
    print(f"\nR3(π/6) - rotation about z-axis:")
    print(R3_matrix)
    print()
    
    print("=== All examples completed successfully! ===")
    print("\nNote: To use rotor_models class, you need a valid JSON configuration file.")
    print("See the test files in casestab/tests/DTU10MW/ for complete examples.")

if __name__ == "__main__":
    import numpy as np
    demonstrate_casestab_usage()
